#ifndef _EVENTCONDITION_H_
#define _EVENTCONDITION_H_
#include "EventArgs.h"
#include "MgrBase.h"
#include "SimpleRefection.h"
class StringRow;
class Reactor;

class EventConditionBase
{
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs) const=0;
	static const char* MakeArchieveName(int32 iAffectorID) 
	{   
		static char szPath[255];
		_snprintf_s(szPath,255,"../../config/EventConditon%02d.xml",iAffectorID);
		return szPath;
	}
	virtual ~EventConditionBase();
};
#define CONNECT_EVENT(EventArg) public: \
static const ECombatEvent MatchEventID= EventArg::EventID;\
EventArg& TrueType(EventArgBase& rEventArgs) const\
{\
	return *((EventArg*)(&rEventArgs));\
}

class EVC_OnCardBeOnBattle:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_OnCardBeOnBattle);
	DECL_REFLECTION(EVC_OnCardBeOnBattle,MakeArchieveName(MatchEventID));
public:

	virtual bool ConditonCheck(EventArgBase& rEventArgs) const {return true;}
	rewrite  virtual void OnArchieveReaded(){}
private:

};

class EVC_OnRoundBegin:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_OnRoundBegin);
	DECL_REFLECTION(EVC_OnRoundBegin,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs) const {return true;}
	virtual void SetData(const StringRow&row){};
	rewrite virtual void OnArchieveReaded(){};
};
class EVC_DoCastSkill:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_DoCastSkill);
	DECL_REFLECTION(EVC_DoCastSkill,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const {return true;};
	virtual void SetData(const StringRow&row){};
	rewrite  virtual void OnArchieveReaded(){}
};
class EVC_ActOver:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_ActOver);
	DECL_REFLECTION(EVC_ActOver,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const {return true;};
	virtual void SetData(const StringRow&row){};
	rewrite  virtual void OnArchieveReaded(){}
};
class EVC_OnRoundOver:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_OnRoundOver);
	DECL_REFLECTION(EVC_OnRoundOver,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const {return true;};
	virtual void SetData(const StringRow&row){};
	rewrite  virtual void OnArchieveReaded(){}
};
class EVC_AfterTakenDamage:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_AfterTakenDamage);
	DECL_REFLECTION(EVC_AfterTakenDamage,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const;
	
	int32 m_iID;
	std::string m_sDisplayName;
	std::vector<int32> m_vDmgTypeIncludes;
	std::vector<int32> m_vDmgTypeExcludes;
	rewrite  virtual void OnArchieveReaded(){}
};
class EVC_AfterMeleeAttackOneTarget:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_AfterMeleeAttackOneTarget);
	DECL_REFLECTION(EVC_AfterMeleeAttackOneTarget,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const;
	
	int32 m_iID;
	std::string m_sDisplayName;
	ETriple m_tiFirstAttackOrNot;
	int32 m_iHpChangeGreaterThan;
	int32 m_iDamageGreaterThan;
	rewrite  virtual void OnArchieveReaded(){}
};
class EVC_BeEstimated:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_BeEstimated);
	DECL_REFLECTION(EVC_BeEstimated,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const;
	virtual void SetData(const StringRow&row){};
	int32 m_iID;
	std::string m_sDisplayName;
	EEstimateResult m_eResultMatch;
	rewrite  virtual void OnArchieveReaded(){}
};

class EVC_BeCaculateDamageLimit:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_BeCaculateDamageLimit);
	DECL_REFLECTION(EVC_BeCaculateDamageLimit,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const;
	
	int32 m_iID;
	std::string m_sDisplayName;
	std::vector<int32> m_vDmgTypeIncludes;
	std::vector<int32> m_vDmgTypeExcludes;
	rewrite  virtual void OnArchieveReaded(){}
};
class EVC_BeCaculateDamageReduce:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_BeCaculateDamageReduce);
	DECL_REFLECTION(EVC_BeCaculateDamageReduce,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const;
	
	int32 m_iID;
	std::string m_sDisplayName;
	std::vector<int32> m_vDmgTypeIncludes;
	std::vector<int32> m_vDmgTypeExcludes;
	ECompare m_eDmgCompare;
	int32 m_iDmgCompareValue;
	rewrite  virtual void OnArchieveReaded(){}
};

class EVC_OnCardDie:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_OnCardDie);
	DECL_REFLECTION(EVC_OnCardDie,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const {return true;};
	virtual void SetData(const StringRow&row){};
private:
	rewrite  virtual void OnArchieveReaded(){}
};

class EVC_OnCardLeaveBattle:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_OnCardLeaveBattle);
	DECL_REFLECTION(EVC_OnCardLeaveBattle,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const {return true;};
	virtual void SetData(const StringRow&row){};
private:
	rewrite  virtual void OnArchieveReaded(){}
};

class EVC_BeforeCastAffectToTargets:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_BeforeCastAffectToTargets);
	DECL_REFLECTION(EVC_BeforeCastAffectToTargets,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const {return true;};
	virtual void SetData(const StringRow&row){};
	rewrite  virtual void OnArchieveReaded(){}
};

class EVC_BeEstimatedAddBuffTo:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_BeEstimatedAddBuffTo);
	DECL_REFLECTION(EVC_BeEstimatedAddBuffTo,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const;
	
	int32 m_iID;
	std::string m_sDisplayName;
	std::vector<int32> m_vBuffTypeIncludes;
	std::vector<int32> m_vBuffTypeExcludes;
	rewrite  virtual void OnArchieveReaded(){}
};
class EVC_OnCardMoveToTomb:public ReflectionBase,public EventConditionBase
{
	CONNECT_EVENT(EventArg_OnCardMoveToTomb);
	DECL_REFLECTION(EVC_OnCardMoveToTomb,MakeArchieveName(MatchEventID));
public:
	virtual bool ConditonCheck(EventArgBase& rEventArgs)const {return true;};
	virtual void SetData(const StringRow&row){};
	rewrite  virtual void OnArchieveReaded(){}
};

//#define MAKEVENTCONID(iEventID,iCondtionID) (iCondtionID*1000+iEventID)
// class EventContionManager:public DefMangerTpl<EventContionManager,EventConditionBase>
// {
// public:
// 	virtual bool	InitLoadData();
// 
// };

#endif